home *** CD-ROM | disk | FTP | other *** search
- DIRECT VIDEO I/O IN FORTRAN
-
- The inter-language calling facilities of the Lahey and Microsoft
- Fortran compilers make it is possible to perform direct I/O to any
- location in memory, including the display adapters. In essence, they
- provide a PEEK/POKE facility without the overhead associated with
- making a subroutine call for each character.
-
- PUTL.FOR shows a main program, and PUT2.FOR a subroutine that
- will write three short pieces of text to a color monitor. The first
- character string will be in ordinary white on black, the second in
- bold white on blue, and the third in flashing yellow on blue.
-
- You can generate PUTL.EXE using the batch file PL.BAT, which will
- call the Lahey compiler and linker to create a runnable unit.
-
- This program uses Lahey F77L's CARG function, which transmits the
- value of its argument to the subroutine, rather than its address. The
- subroutine, PUT_IT, however thinks that it is being passed the address
- of an array, which it is to write in. What appears to be the address
- of the array SCREEN is actually a constant data item pointing to the
- address of the color text area of a PC's memory. (In order to write
- to a monochrome adapter, the value B8000000 should be changed to
- B0000000.)
-
- PUTM.FOR is an alternate main program, set up to do the same
- thing using Microsoft's compiler. The differences from the Lahey
- version are: 1) the addition of an INTERFACE statement which specifies
- that the first argument to PUT_IT is to be passed by value, and 2) the
- format for expressing a hexadecimal number when ICRT is given a value.
- Subroutine PUT_IT is not listed, as it is identical with the previous
- version, and we can use the one in file PUT2.FOR again (as long as it
- is recompiled with the MS compiler!).
-
- You can generate PUTM.EXE by using the batch file PM.BAT, which
- invokes compiler and linker.
-
- Microsoft Fortran will issue a warning message if the main
- program and the subroutine are compiled in one file, as it will detect
- the disagreement in the argument lists. This is why PUT_IT is sitting
- in a file by itself: so that the compiler can not figure out what we
- are doing.
-
- The same tricks can be used to read data back from the screen.
- GETL.FOR contains an F77L program that will read 40 characters from
- the video adapter, starting at column 5, line 10. (These numbers are
- arbitrary - you can see where they are being passed as arguments to
- GET_IT.) Subroutine GET_IT, which is in file GET2.FOR, strips off the
- graphic attribute byte and stores the plain character into the
- CHARACTER variable that is passed to it. GETM.FOR is the same main
- program, but written for the Microsoft compiler; again, the
- subroutine GET_IT is identical to that used with F77L.
-
- To generate the screen reading programs, use either GL.BAT (for
- Lahey) or GM.BAT (for Microsoft).
-
-
- 1
- PAGE 2
-
-
- A few subroutines using these techniques can form the basis for
- some simple pop-up windows, without the need for assembly language or
- third-party packages. When it is necessary for a window to appear on
- the screen, the needed area (both characters and attributes) can be
- read and stored into an array. The new box can be written to the
- screen, and then, when it is to disappear, the original contents of
- that region can be restored from the array.
-
- Many varieties of personal computer can be identified by
- examining the System ID Byte, which is stored at FFFF:000E. For
- example, a real IBM AT has "FC" (hex) stored there. Two programs are
- provided (one for use with each compiler) to read and report the value
- of this byte: for Lahey, the file is MACHIDL.FOR, and for Microsoft it
- is MACHIDM.FOR.
-
- Note that the Microsoft compiler will complain about an argument
- mismatch when calling PEEKB0 - this is because it has figured out that
- we are passing the first argument (the address) by value, and then
- using it to read by reference inside the subroutine. If this bothers
- you (personally, I prefer to have ALL the error messages go away),
- then you can deprive the compiler of the information that is necessary
- to identify this condition by compiling PEEKB0 separately, as we did
- with GET_IT and PUT_IT.
-
- After examining how these programs work, you should be able to
- create your own PEEK and POKE routines whenever they are needed.
-
- If these files are useful to you, DO NOT send money - a simple
- "thank you" would be appropriate. Also, find something that others
- (like me) would find useful, and post it on this bulletin board. And,
- do it in Fortran, not "C" - so that grownups can use it.
-
-
- Kenneth G. Hamilton, Ph.D.
- P. O. Box 9388
- San Diego CA 92169-0388
- CompuServe [72727,177]
- GEnie K.HAMILTON3
-
- ----------------end-of-author's-documentation---------------
-
- Software Library Information:
-
- This disk copy provided as a service of
-
- Public (software) Library
-
- We are not the authors of this program, nor are we associated
- with the author in any way other than as a distributor of the
- program in accordance with the author's terms of distribution.
-
- Please direct shareware payments and specific questions about
- this program to the author of the program, whose name appears
- elsewhere in this documentation. If you have trouble getting
- in touch with the author, we will do whatever we can to help
- you with your questions. All programs have been tested and do
- run. To report problems, please use the form that is in the
- file PROBLEM.DOC on many of our disks or in other written for-
- mat with screen printouts, if possible. PsL cannot debug pro-
- programs over the telephone, though we can answer questions.
-
- Disks in the PsL are updated monthly, so if you did not get
- this disk directly from the PsL, you should be aware that the
- files in this set may no longer be the current versions. Also,
- if you got this disk from another vendor and are having prob-
- lems, be aware that some files may have become corrupted or
- lost by that vendor. Get a current, working disk from PsL.
-
- For a copy of the latest monthly software library newsletter
- and a list of the 2,000+ disks in the library, call or write
-
- Public (software) Library
- P.O.Box 35705 - F
- Houston, TX 77235-5705
-
- Orders only:
- 1-800-2424-PSL
- MC/Visa/AmEx/Discover
-
- Outside of U.S. or in Texas
- or for general information,
- Call 1-713-524-6394
-
- PsL also has an outstanding
- catalog for the Macintosh.
-
-